package tech.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.aistar.pojo.Product;
import tech.aistar.pojo.Result;
import tech.aistar.service.ProductService;

import java.util.List;

/**
 * 服务器上的资源包括静态在于和动态资源(代码)
 */
@RestController
@RequestMapping("product")
public class ProductController {
    //controller层调用service层,声明service
    @Autowired
    private ProductService productService;

    @GetMapping
    public Result index(){
        //调用service
        List<Product> productList = productService.listAll();
        return Result.success(productList);
    }
}